package com.example.demo.controller;

import com.example.demo.common.entity.ParamBase;
import com.example.demo.common.entity.ParamPage;
import com.example.demo.common.util.BucnInvoker;
import com.example.demo.common.util.ListResult;
import com.example.demo.common.util.OptResult;
import com.example.demo.service.TestUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "*用户管理", value = "用户", description = "用户")
@RestController
@RequestMapping("ly/mp/clue/testuser")
public class TestUserController {

    @Autowired
    TestUserService testUserService;

    @ApiOperation("查询")
    @PostMapping("userpage.do")
    public ListResult<Map<String, Object>> userPage(@RequestBody ParamPage<Map<String, Object>> paramPage,
                                                    @RequestHeader(HttpHeaders.AUTHORIZATION) String token) {
        return BucnInvoker.doList(() -> testUserService.page(paramPage));
    }

    @ApiOperation("保存")
    @PostMapping("usersave.do")
    public OptResult userSave(@RequestBody ParamBase<Map<String, Object>> paramBase,
                              @RequestHeader(HttpHeaders.AUTHORIZATION) String token) {
        return BucnInvoker.doOpt(() -> testUserService.save(paramBase, token));
    }


}